<?php
class Member extends CI_Model{
	function __construct(){

		parent::__construct();

	}

	function cek_member_login($NIM, $password){

		$this->db->select('*');
		$this->db->where('NIM', $NIM);
		$this->db->where('password', $password);
		$query = $this->db->get('member');


		if($query->num_rows() > 0){
			return $query->row_array();
		}
	}

	function getDetailMember($NIM){
		$this->db->select('*');
		$this->db->where('NIM', $NIM);
		$query = $this->db->get('member');

		return $query->result_array();
	}

	function getDivisi($id){
		$divisi = "";
		if($id = '1'){
			$divisi = "Desktop Programming";
		}else if($id = '2'){
			$divisi = "Web Programming";
		}else if($id = '3'){
			$divisi = "Jaringan";
		}else if($id = '4'){
			$divisi = "Hardware";
		}

		return $divisi;
	}

	function getPhoto($NIM){
		return "http://www.amikom.ac.id/public/fotomhs/20".substr($NIM, 0,2)."/".$NIM.".jpg";
	}

	function updateMember($NIM, $namaL, $namaP, $alamat, $telp, $email, $pwd){
		$str = "UPDATE member SET nama = '$namaL', password = '$pwd', alamat = '$alamat', telp = '$telp', email = '$email' WHERE NIM = '$NIM';";
		$query = $this->db->query($str);

        if ($this->db->affected_rows() > 0) {
            return true;
        } else {
            return false;
        }
	}

}